<template>
  <el-button type="text" @click="clickHandle">{{ text }}</el-button>
</template>
<script>
const cap = {
  name: 'CAbnormalPreview',
  props: {
    to: {
      type: Object,
      default: () => ({})
    },
    text: {
      type: String,
      default: '异常提报记录查看'
    },
    path: {
      type: String,
      default: ''
    },
    query: {
      type: Object,
      default: () => ({})
    }
  },
  methods: {
    clickHandle() {
      if (this.path) {
        this.toPage()
      } else {
        this.$router.push(this.to)
      }
    },
    toPage() {
      if (!this.path) return
      this.$store.dispatch('views/goPage', { path: this.path, query: this.query })
    }
  }
}
export default cap
export const capInstall = {
  install(Vue) {
    Vue.component(cap.name, cap)
  }
}
</script>
